<?Lassoscript
// last modified: 3/15/05 by ECL, Landmann InterActive

// FUNCTIONALITY
// Customer Info form

// Debugging
// Var:'svDebug' = 'Y';

// Convert action_params
Include:($svLibsPath)'info_params.inc';

//start captcha
		var:	'code'=(lasso_uniqueid),
				'max_length'= 7,
				'unreadable_chars'=(array:'o','O','0'),
				'seed'='secret code',
				'code_encrypted'='';
		
		iterate:$unreadable_chars,(var:'current');
			$code->(replace($current,''));
		/iterate;
		
		$code=($code->(substring:($code->length-$max_length),$max_length));
		$code_encrypted=(encrypt_blowfish: $code, -seed=$seed);
// end captcha


// If Edit page, get the record
If: (Response_Filepath) >> 'setup_editrecord.lasso';
	// If Process = Y, form was submit, so update the record
	// Otherwise, it is a new edit so get the record
	If: $vProcess != 'Y';
		// Get the record
		Var:'vSQLSearchContactInfo'='SELECT *
			FROM ' $svContactInfoTable ' WHERE ID = "'($vID)'" LIMIT 1';
		Inline: $IV_SearchContactInfo, -SQL=$vSQLSearchContactInfo;
			// If Found_Count is wrong, the wrong ID was passed, so dump out 2000 "No Record Found"	
			If: (Found_Count) == 0;
				Var:'vError' = '2000';
				Abort;
			/If;
			Var:'vID' = Field:'ID';
			Var:'vName' = Field:'Name';
			Var:'vAge' = Field:'Age';
			Var:'vEmail' = Field:'Mail';
			Var:'vPhone' = Field:'Phone';
			Var:'vAddress' = Field:'Address';
			Var:'vCity' = Field:'City';
			Var:'vState' = Field:'State';
			Var:'vComment' = Field:'Comment';
			Var:'vDisplay' = Field:'Display';
			Var:'vDateCreated' = Field:'DateCreated';
		/Inline;
	Else;
		// Update the record
		Inline: $IV_UpdateContactInfo, 'ID' = $vID;
			// If there is an error, dump out error 1012 "Update Failed"
			If: (Error_CurrentError) != 0;
				Var:'vError' = '1012';
			/If;
		/Inline;
	/If;
	
/If;

'<h2>Customer Info</h2>\n';

// Show only if not coming from the Forums add page
// If: (Response_Filepath) !>> 'thread' || (Response_Filepath) >> 'consumer' || (Response_Filepath) !>> 'addresponse';
//If:  ((Response_Filepath) !>> 'consumer') && ((Var:'vNew') != 'Y');
//If: ((Response_Filepath) !>> 'consumer');
//If: ((Response_Filepath) >> 'setup');
If: ((Response_Filepath) >> 'setup') || ((Referrer_URL) >> 'consumer');
	// Standard Error Table
	If: (Var:'vError') != '';
		LI_ShowError3: -ErrNum=$vError, -Option=$vOption;
	/If;
/If;
///If;

// Defining the response page, as the same form is used for consumer input and admin edit/approval
// If Response_Filepath is setup_edit.lasso, request came from Admin
// If Response_Filepath is setup_editrecord.lasso, request came from Admin area Update action
// If Response_Filepath contains "consumer", request came from the consumer input form
If: (Response_Filepath) >> 'consumer';
	Var:'vResponsePage' = 'consumerinfo_response.lasso';
Else: (Response_Filepath) >> 'setup_edit' || (Response_Filepath) >> 'setup_add';
	Var:'vResponsePage' = 'setup_addresponse.lasso';
/If;
?>
<form action="[$vResponsePage]" method="post">
	<table width="450" border="0" cellpadding="1" cellspacing="1">
		<tr>
			<td colspan="2">
				<div align="center">
				[If: (Response_Filepath) >> 'consumer']
					<div class="notice">Thank you for sharing your comments, testimonials and stories with us. We value your feedback and may include your comments in our marketing.</div>
				[/If]
					<br>
					<strong>PLEASE NOTE: </strong>[$svInputRequired] indicates required information. 
				</div>
			</td>
		</tr>
[If: ((Response_Filepath) !>> 'setup_add')]
	[If: (Response_Filepath) !>> 'consumer']
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">ID</font></strong>
				</p>
			</td>
			<td width="350" valign="middle" bgcolor="[Var:'svPostContentColor']">
				  [Var:'vID']
			</td>
		</tr>
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Date Created</font></strong>
				</p>
			</td>
			<td width="350" valign="middle" bgcolor="[Var:'svPostContentColor']">
				  [Var:'vDateCreated']
			</td>
		</tr>
	[/If]
[/If]
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Name</font></strong>[$svInputRequired]
				</p>
			</td>
			<td width="350" valign="top" bgcolor="[Var:'svPostContentColor']">
				<input type="text" name="Name" value="[Var:'vName']" size="30" maxlength="80">
			</td>
		</tr>
		<tr>
			<td width="100" bgcolor="[Var: 'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Age</font></strong>
				</p>
			</td>
			<td width="350" valign="top" bgcolor="[Var:'svPostContentColor']">
				<input type="text" name="Age" value="[Var:'vAge']" size="6" maxlength="4">
			</td>
		</tr>
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">E-mail</font></strong>
				</p>
			</td>
			<td width="350" bgcolor="[Var:'svPostContentColor']" valign="top">
				<input type="text" name="Email" value="[Var:'vEmail']" size="24" maxlength="64">
			</td>
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Phone</font></strong>
				</p>
			</td>
			<td width="350" bgcolor="[Var:'svPostContentColor']" valign="top">
				<input type="text" name="Phone" value="[Var:'vPhone']" size="24" maxlength="64">
			</td>
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Address</font></strong>[$svInputRequired]
				</p>
			</td>
			<td width="350" bgcolor="[Var:'svPostContentColor']" valign="top">
				<input type="text" name="Address" value="[Var:'vAddress']" size="40" maxlength="128">
			</td>
		</tr>
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">City</font></strong>[$svInputRequired]
				</p>
			</td>
			<td width="350" bgcolor="[Var:'svPostContentColor']" valign="top">
				<input type="text" name="City" value="[Var:'vCity']" size="24" maxlength="64">
			</td>
		</tr>
		<tr>
			<td width="100" bgcolor="[Var: 'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">State</font></strong>[$svInputRequired]
				</p>
			</td>
			<td width="350" valign="top" bgcolor="[Var:'svPostContentColor']">
				<input type="text" name="State" value="[Var:'vState']" size="9" maxlength="18">
			</td>
		</tr>
		<tr>
			<td width="100" bgcolor="[Var: 'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Comment</font></strong>
				</p>
			</td>
			<td width="350" bgcolor="[Var:'svPostContentColor']" valign="top">
<textarea name="Comment" cols="40" rows="6">[Var:'vComment']</textarea>
			</td>
		</tr>
	[If: (Response_Filepath) >> 'consumer']
		<tr>
			<td width="100" bgcolor="[Var: 'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Please enter the security code shown[$svInputRequired]</font></strong>
				</p>
			</td>
			<td width="350" bgcolor="[Var:'svPostContentColor']" valign="top">
				<table align="left" width="80%"><tr><td>
				<img src="secure_serve.lasso?s=[$code_encrypted]" border="0" width="200" height="100">
				</td></tr>
				<tr><td>
				<input type="text" name="number" size="24">
				<strong>Security Code is case sensitive.<br></strong>If security code is off the grid or unreadable refresh your browser.
				<input type="hidden" name="s" value="[$code_encrypted]">
				</td></tr></table>
			</td>
		</tr>
	[/If]	
	[If: (Response_Filepath) !>> 'consumer']
		<tr>
			<td width="100" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<strong><font color="#FFFFFF">Display</font></strong>[$svInputRequired]
				</p>
			</td>
			<td width="350" valign="middle" bgcolor="[Var:'svPostContentColor']">
				<select name="Display"> 
					<option value="" [if: (var:'vDisplay') == ''] selected[/If]></option>
					<option value="Y" [if: (var:'vDisplay') == 'Y'] selected[/if]>Yes</option>
					<option value="N" [if: (var:'vDisplay') == 'N'] selected[/if]>No
					</option>
				</select> 
			</td>
		</tr>
[/If]
		<tr>
			<td colspan="2" bgcolor="[Var:'svPostHeaderColor']">
				<div align="center">
<?Lassoscript
// If Edit page, add a hidden field to show check if page is submit
// Also add a hidden field with the User_ID
If: (Response_Filepath) >> 'setup_editrecord.lasso';
				'\t\t\t\t<input type="hidden" name="Process" value="Y">\n';
				'\t\t\t\t<input type="hidden" name="ID" value="'($vID)'">\n';
				'\t\t\t\t<input type="hidden" name="DataType" value="Test">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Update">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Delete">\n';
Else;
				'\t\t\t\t<input type="hidden" name="DataType" value="Test">\n';
				'\t\t\t\t<input type="hidden" name="SID" value="'($vSID)'">\n';
				'\t\t\t\t<input type="hidden" name="TID" value="'($vTID)'">\n';
				'\t\t\t\t<input type="hidden" name="DateCreated" value="'(Server_Date:-Extended)'">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Add">\n';
/If; ?>				</div>
				</div>
			</td>
		</tr>
	</table>
</form>
